﻿<%
Class sangong_class
    Public Function online()
        dim rs,sql,str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select count(*) as nid FROM qingtian_reton"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
		str=rs("nid")
	else
		str=0
	end if
	Rs.close
	set rs=nothing
	online=str
     End Function
    Public Function tj()
        dim rs,sql,i
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where nid="&qingtian.nid
	Rs.Open Sql,cn,1,3
	if not (rs.bof and rs.eof) then
        rs("time")=now
	else
	rs.addnew
        rs("time")=now
	rs("nid")=qingtian.nid
	end if
	rs.update
	Rs.close
     End Function
    Public Function pd(str)
        dim rs,sql,strr
        strr=str
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select money FROM qingtian_fangjian where id="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
           if conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")<rs("money") then
           qingtian.err("你的"&qingtian.bi&"不足,进入该房间最小需要"&rs("money")&""&qingtian.bi&".<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
           end if
        else
           qingtian.err("没有该房间,<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function moname(str)
        dim rs,sql,i,strr,moname1
        strr=str
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
	For i=1 to rs.RecordCount
        if i=1 then
        moname1="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>"
        else
        moname1="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>" & "," & moname1
        end if
	Rs.MoveNext
	next
        else
        moname1="暂无玩家"        
	end if
	Rs.close
	set rs=nothing
        moname=moname1
     End Function
    Public Function moname3(str,str2)
        dim rs,sql,i,strr,strr2
        strr=str
        strr2=str2
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 nid FROM qingtian_reton where aid="&strr&" and ton=2"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname3="(<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>)"
        else
        moname3="(空)[<a href='gamed.asp?act=1&amp;pid="&strr2&"&amp;id="&strr&"&amp;sid="&sidd&"'>坐庄</a>]"     
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function moname2(str,str2)
        dim rs,sql,i,strr,strr2
        strr=str
        strr2=str2
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr&" and ton<>2"
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
	For i=1 to rs.RecordCount
        if i=1 then
        moname2="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>"
        else
        moname2="<a href='/user/spacev.asp?urls=/game/sangon/index.asp&amp;nid="&rs("nid")&"&amp;sid="&sidd&"'>"&qingtian.name(rs("nid"))&"</a>" & "," & moname1
        end if
	Rs.MoveNext
	next
        else
        moname2="空"     
	end if
	Rs.close
	set rs=nothing
        moname2="("&moname2&")[<a href='gamed.asp?act=2&amp;pid="&strr2&"&amp;id="&strr&"&amp;sid="&sidd&"'>坐闲</a>]"
     End Function
    Public Function tonn()
        dim rs,sql
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select ton,aid,bid FROM qingtian_reton where nid="&qingtian.nid
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        if rs("ton")<>0 then
        tonn="状态:游戏中<a href='gamed.asp?action=login&amp;pid="&rs("bid")&"&amp;id="&rs("aid")&"&amp;sid=" & sidd & "'>返回</a>"
        else
        tonn="状态:等待游戏"
	end if
	end if
	Rs.close
	set rs=nothing
     End Function
    Public Function mobe(str)
        dim rs,sql,i,strr,moname1
        strr=str
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select nid FROM qingtian_reton where aid="&strr
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs.RecordCount&"人"
        else
        moname1="空闲"
	end if
	Rs.close
	set rs=nothing
        mobe=moname1
     End Function
    Public Function moton(str,str1,str2)
        dim rs,sql,i,strr,strr1,strr2
        strr=str
        strr1=str1
        strr2=str2
        select case strr
        case "0"
        moton="等待加入"
        case "1"
        moton="正在进行"
        End Select
     End Function
    Public Function namefa(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_fangd where id="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
        else
        qingtian.err("没有该房间,<a href='index.asp?sid=" & sidd & "'>返回重选房间</a>")
	end if
	Rs.close
	set rs=nothing
        namefa=moname1
     End Function
    Public Function namere(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_reton where nid="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
	end if
	Rs.close
	set rs=nothing
        namere=moname1
     End Function
    Public Function namejian(str,str1)
        dim rs,sql,strr,moname1,strr1
        strr=str
        strr1=str1
        moname1=""
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select "&strr&" FROM qingtian_fangjian where id="&strr1
	Rs.Open Sql,cn,1,1
	if not (rs.bof and rs.eof) then
        moname1=rs(0)
	end if
	Rs.close
	set rs=nothing
        namejian=moname1
     End Function
end class
set sangong=new sangong_class
%>
